package com.ultra.util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;

import com.ultra.config.AppConfig;

/** 
 * @ClassName: ImgUtil 
 * @Description: 图片处理类
 * @author jiangshidi QQ:82421098 
 * @date 2013-4-10 下午5:26:34 
 *  
 */
public class ImgUtil{
	
	/** @Fields BG : 背景图片传参类型 */ 
	public final static int BG = 0;
	/** @Fields WA : 艺术字传参类型 */ 
	public final static int WA = 1;
	public final static int IC = 2;
	/** @Fields BG : 背景图片路径 */ 
	private final static String BG_PATH = "bg";
	/** @Fields WA_PATH : 艺术字路径 */ 
	private final static String WA_PATH = "wordArt";
	private final static String IC_PATH = "icon";
	/** 
	 * @Title: getImgDrawable 
	 * @Description: 根据图片类型及名称,取背景。
	 * @param @param imgURL
	 * @param @return    设定文件 
	 * @return Drawable    返回类型 
	 * @throws 
	 */
	public static Drawable getImgDrawable(int drwType, String imgURL){
		Drawable drw = null ;
		String path = "";
		switch (drwType) {
		case BG:
			path = BG_PATH;
			break;
		case WA:
			path = WA_PATH;
			break;
		case IC:
			path = IC_PATH;
			break;
		default:
			break;
		}
		imgURL = FileUtil.getSdcardPath() + SymbolUtil.SEPARATOR + AppConfig.IMG_PATH + AppConfig.SUBJECT_COLOUR + SymbolUtil.SEPARATOR + path +SymbolUtil.SEPARATOR + imgURL;
		Bitmap bitmapOrg = BitmapFactory.decodeFile(imgURL);
		if(bitmapOrg != null){
			bitmapOrg.setDensity(DisplayMetrics.DENSITY_LOW);
			drw = new BitmapDrawable(bitmapOrg);
		}
		return drw;
	}
}